package com.sacodemel.financeiro.util;

import java.io.IOException;
import java.util.ResourceBundle;

public class ResourceService {
    
    private ResourceBundle resouce;
    private static ResourceService resourceService;
    public static final String CONFIG = "config";
    
    private ResourceService(String arquivo)
    throws IOException {

        try {

            resouce = ResourceBundle.getBundle(arquivo);

        } catch(NullPointerException e) {
            throw new NullPointerException("(Query - construtor)Exception " + e.getMessage());
        }
    }
    
    public static ResourceService getInstance(String arquivo)
    throws IOException {
        if(resourceService == null)
        {
        	resourceService = new ResourceService(arquivo);
        }
        return resourceService;
    }
    
    public void load(String arquivo)
    throws IOException {
        try {
            resouce = ResourceBundle.getBundle(arquivo);
        } catch(NullPointerException e) {
            throw new NullPointerException("(Query - construtor)Exception " + e.getMessage());
        }
    }


    public String getProperty(String chave) {
        return resouce.getString(chave);
    }



}
